package com.fingard.dsp.bank.reqrespobj.single.detail;

import com.fingard.FGBiz;
import com.fingard.constant.Format;
import com.fingard.crypto.TripleDESHelper;
import com.fingard.dsp.bank.directbank.specialDeal.BankAreaHelper;
import com.fingard.text.StringHelper;
import com.fingard.xml.XElement;
import com.vbao.frame.common.validation.annotation.Amount;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;

/**
 * 普通单笔支付、批量代收付的明细节点
 */
public class ReqPayRecDetail {
    //收方开户行英文名
    public String recBankInEng;

    //境外支付新增字段
    //付款账户所在国家代码
    public String payCountryCode;
    //收方银行在MYR时候的POP信息(Purpose of Payment)
    public String popCode;
    //手续费承当方
    public String feePayer;
    //收款账户SwiftBIC
    public String recSwiftCode;
    //Unitcode 申请方组织机构代码
    public String payOrgCode;
    //收款账户国家代码
    public String recCountry;
    //本笔款项是否为保税货物项下的款项
    public String isBondedGood;
    //付款方式 A=预付货款 P=货到付款 R=退款  O=其他
    public String payMethod;
    // 交易代码 如321000 职工报酬(工资、薪金和福利)、投资收益、直接投资股息,红利……
    public String transCode1;
    //监管信息-Currency币种1
    public String currency1;
    //监管信息-amount1收付金额1
    public String amount1;
    //监管信息-交易备注1
    public String transRemark1;
    // 交易代码 如321000 职工报酬(工资、薪金和福利)、投资收益、直接投资股息,红利……
    public String transCode2;
    //监管信息-Currency币种2
    public String currency2;
    //监管信息-amount1收付金额2
    public String amount2;
    //监管信息-交易备注2
    public String transRemark2;
    //合同号
    public String contractNo;
    //发票号
    public String invoiceNo;
    //外汇局批件/备案表号/业务编号
    public String safeOrFillingNo;
    // 外汇交易编码
    public String transCode;
    // 汇款附言
    public String remittanceInfor;

    /**支付流水号*/ 
    public String askNumber;

    /**付方户名*/ 
    public String payName;

    /**付方账号*/ 
    public String payAct;

    /**付方银行*/ 
    public String payBankName;
    public String payBankCode;

    /**付方银行开户行*/ 
    public String payBankLocation;
    /**付方银行开户行代码*/ 
    public String payBankLocationCode;
    /**付方组织机构代码证*/
    public String payOrganizationCode;

    // 付方区域
    public String payArea;

    // 付方区域名称
    public String payAreaName;
    public String payStandardArea;

    // 收方名称
    public String recName;

    // 收方账户
    public String recAct;

    // 收付银行
    public String recBankName;
    public String recBankCode;

    // 收方银行开户行
    public String recBankLocation;
    
    /** 收方开户银行地址 */
    public String recBankAddress;
    
    /** 收方地址 */
    public String recNameAddress;
    
    /** 收方代理行账号 */
    public String recAgentBankAccount;

    // 收方区域
    public String recArea;

    // 收方区域名称
    public String recAreaName;
    public String recStandardArea;

    /**
     * 同城标志 (1：同城,   0：异地)
     */
    public String sameCity;

    /**
     * 同行标志 (1：同行,   0：他行)
     */
    public String sameBnk;

    // 付款日期
    public String payDate;

    // 付款时间
    public String payTime;

    // 付方金额
    public String payAmount;

    // 付方币种
    public String payCur;

    // 收方币种
    public String recCur;

    /**用途，对应资金系统purpose*/
    public String purpose;

    /**代收付用途*/ 
    public String useType;

    // 加急 1-加急
    public String paySpd;

    // 提交人
    public String submitID;

    // 对账码，对应资金系统abstract
    public String abstractATS;

    // 备注
    public String memo;

    //描述
    public String description;

    // 是否内部转账
    public String innerPay;

    // 付方是否为总公司 1-总公司 0-子公司
    public String rootPay;

    // 收方是否为总公司 1-总公司 0-子公司
    public String rootRec;

    /**
     * 卡折标志
     * 1	折
     * 2	借记卡
     * 3	贷记卡
     * 4	准贷记卡
     */
    public String cardType;


    /**
     * 公私标志  (1:对私,   其它:对公)
     */
    public String isPrivate;
    //联行号
    public String cnapsCode;
    //联行号名称
    public String cnapsName;

    //境外费用承担字段
    public String costMode = "";

    /**
     * 鉴权标志  0：不鉴权   1: 鉴权
     */
    public String verifyFlag;

    /**
     * 0	身份证
     * 1	户口簿
     * 2	护照
     * 3	军官证
     * 4	士兵证
     * 5	港澳居民来往内地通行证
     * 6	台湾同胞来往内地通行证
     * 7	临时身份证
     * 8	外国人居留证
     * 9	警官证
     * 10/A 港澳台居民居住证，数字10或字母A
     * 99/Z	其他证件，数字99或字母Z
     */
    public String certType;
    public String certNum;
    public String payType;
    public String sourceNote;
    public String sourceNoteCode;
    public String oriSourceNoteCode;
    /** 客户号 */
    public String customNo = "";
    public String createIP;
    public String channelAuthCode;

    private String transType = "";
    public String ownBankCode = "";
    /**
     * 信用卡有效期
     */
    public String expiredDate;
    /**
     * 信用卡cvv2码
     */
    public String cvv2;
    /**
     * 协议编号
     */
    public String authAgNum;
    /**
     * 缴费编号，扣款授权编号
     */
    public String authCode;
    /**
     * 授权号
     */
    public String authId;
    /**
     * 手机号码
     */
    public String cellPhone;
    /**
     * 短信验证码
     */
    public String smsCode;
    public XElement srcXElement;

    /**
     * 上划下拨标识:(0-上划,1-下拨)
     */
    public String primaryAct;

    public String coucde;
    public String payTopLevelAct;//付方顶级账户
    public String payHigherLevelAct;//付方上级账户
    public String recTopLevelAct;//收方顶级账户
    public String recHigherLevelAct;//收方上级账户

    public String innerAct;//代理账户账号
    public String innerName;//代理账户户名

    public String reqReserved1;
    
    public String reqReserved2;
    
    public String isCardBind;
    /** 用户ID */
    public String userId;
    
    /** 缩略卡号 */
    public String shortCardNo;
    
    /** 缩略手机号 */
    public String shortPhoneNo;
    
    /** 预留字段 */
    public String attach;

    /**
     * 预约日期
     */
    public String bookDate;
    
    /**
     * 工作日标识，1是工作日，0非工作日，农行浙江省行智惠保引入
     * */
    public String workDayFlag;
    
    /**是否重用批次号*/
    public String reuseSeq = "";
    
    /** 投保单号 */
    public String insuPolicyNum = "";
    /** 险种id */
    public String insureID;
    /** 险种名称 */
    public String insureName;
    /** 险种名称 */
    public String noteMoney;
    
    /** 是否为保税货物项下付款 */
    public String isBondedGoods = "";
    
    /** 付汇性质 */
    public String payProp;  
    
    /** 组织机构代码 */
    public String orgCode;  
    
    /** 收款银行之代理行名称 */
    public String recAgtBankName;
    
    /** 收款银行之代理行地址 */
    public String recAgeBankAddr;
    
    /** 交易附言 */
    public String transInfo;
    
    // 实名制字段
    /** 是否实名标志 (1-是,0-否) */
    public String realNameFlag;
    
    /** 实名类型(0-全国车险、1-上海车险、2-深圳车险) */
    public String realNameType;

    /** 平台校验码 */
    public String circPaymentNo;

    /** 车险平台商户号 */
    public String circMchNo;

    /** 用户编号 */
    public String userCode;
    
    /** 用户名称 */
    public String userName;
    
    /** 支付号 */
    public String paymentCode;
    
    /** 银行ID */
    public String bkName;
    
    /** 业务类型 */
    public String lioperType;
    
    /** 结构 */
    public String branchCode;
    
    /** 渠道 */
    public String channel;
    
    /** 项目代码 */
    public String termID;

    /** 预算项目编号 */
    public String budgetItemCode;

    /** 投保单号 */
    public String attribute11;

    /** 唯一业务号 */
    public String attribute12;

    /** 订单号 */
    public String attribute13;

    /** 资金类别 */
    public String attribute14;

    /** 资金子类别 */
    public String attribute15;

    /** 保单所属末级机构 */
    public String attribute16;

    /** 业务类型 */
    public String attribute17;

    /** 来源 */
    public String attribute18;

    /** 险种 */
    public String attribute19;

    /** 是否虚拟户标识 1-是，0-否 */
    public boolean isVirtual;

    /** 虚拟户编号 */
    public String virtualNo;

    /**
     * 订单号
     */
    public String orderNo;

    /**
     * 生效日
     */
    public String effectDate;
    /**
     * 起始日
     */
    public String beginDate;
    /**
     * 缴至日
     */
    public String endDate;
    /**
     * 保单号上送标志
     */
    public String insFlag;

    /**
     * 追加首期请款期数标志
     */
    public String addFlag;
    /**
     * 追加首期请款期数
     */
    public String addNum;

    /**
     * 计划变更标志
     */
    public String planChgFlag;

    /**
     * 变更前的计划
     */
    public String planBefore;
    /**
     * 变更后的计划
     */
    public String planAfter;
    /**
     * 缴别变更标志
     */
    public String pfqChgFlag;
    /**
     * 变更前的缴别
     */
    public String pfqBefore;
    /**
     * 变更后的缴别
     */
    public String pfqAfter;
    /**
     * 出生日期变更标志
     */
    public String bdtChgFlag;
    /**
     * 变更前的出生日期
     */
    public String bdtBefore;
    /**
     * 变更前的出生日期
     */
    public String bdtAfter;
    /**
     * 性别变更标志
     */
    public String sexChgFlag;

    /**
     * 变更前的性别
     */
    public String sexBefore;
    /**
     * 变更后的性别
     */
    public String sexAfter;
    /**
     * 是否收取手续费
     */
    public String feeChaFlag;

    /**
     * 子订单标志
     */
    public String subOrderFlag;
    /**
     * 订单序号
     */
    public String orderSeq;

    /**
     * 订单生效时间(格式：yyyyMMddHHmmss)
     */
    public String timeStart;

    public String authSeqID;

    public ReqPayRecDetail(){
    	
    }

    public ReqPayRecDetail(Map<String,String> map){
        String transType = map.get("TransType");
        if ("SubmitTransferOrder".equalsIgnoreCase(transType)) {
            payAct = map.get("OurBankAccount");
            recAct = map.get("OpenId");
            askNumber = map.get("RdSeq");
            description = map.get("Description");
            recCur = map.get("Cur");
            payAmount = map.get("Amount");
            recName = map.get("OppActName");
            timeStart = map.get("TimeStart");
            realNameFlag = map.get("RealNameFlag");
        } else {
            payAct = map.get("PayAct");
            recAct = map.get("RecAct");
            payAmount = map.get("PayAmount");
            askNumber = map.get("RdSeq");
            memo = map.get("Memo");
        }
    }
    
    public ReqPayRecDetail(XElement p_xelement, String p_transType, String p_bankCode) throws Exception {
    	initData(p_xelement, p_transType, p_bankCode, "");
    }
    
    public ReqPayRecDetail(XElement p_xelement, String p_transType, String p_bankCode, String pPayType) throws Exception {
    	initData(p_xelement, p_transType, p_bankCode, pPayType);
    }

    private void initData(XElement p_xelement, String p_transType, String p_bankCode, String pPayType) throws Exception {
        srcXElement = p_xelement;
        transType = p_transType;
        orderNo = p_xelement.getSingleTextNotNull("OrderNumber");
        effectDate = p_xelement.getSingleTextNotNull("EffectDate");
        if (StringHelper.isNullOrEmpty(effectDate)) {
            effectDate = Format.Date8Format.format(new Date());
        }
        beginDate = p_xelement.getSingleTextNotNull("BeginDate");
        endDate = p_xelement.getSingleTextNotNull("EndDate");
        insFlag = p_xelement.getSingleTextNotNull("InsFlag");
        addFlag = p_xelement.getSingleTextNotNull("AddFlag");
        addNum = p_xelement.getSingleTextNotNull("AddNum");
        if (StringHelper.isNullOrEmpty(addNum)) {
            addNum = "0";
        }
        planChgFlag = p_xelement.getSingleTextNotNull("PlanChgFlag");
        planBefore = p_xelement.getSingleTextNotNull("PlanBefore");
        planAfter = p_xelement.getSingleTextNotNull("PlanAfter");
        pfqChgFlag = p_xelement.getSingleTextNotNull("PfqChgFlag");
        pfqBefore = p_xelement.getSingleTextNotNull("PfqBefore");
        pfqAfter = p_xelement.getSingleTextNotNull("PfqAfter");
        bdtChgFlag = p_xelement.getSingleTextNotNull("BdtChgFlag");
        bdtBefore = p_xelement.getSingleTextNotNull("BdtBefore");
        bdtAfter = p_xelement.getSingleTextNotNull("BdtAfter");
        sexChgFlag = p_xelement.getSingleTextNotNull("SexChgFlag");
        sexBefore = p_xelement.getSingleTextNotNull("SexBefore");
        sexAfter = p_xelement.getSingleTextNotNull("SexAfter");
        feeChaFlag = p_xelement.getSingleTextNotNull("FeeChaFlag");
        subOrderFlag = p_xelement.getSingleTextNotNull("SubOrderFlag");
        orderSeq = p_xelement.getSingleTextNotNull("OrderSeq");
        if(StringHelper.hasAnyChar(orderSeq)) {
            orderSeq = "0" + orderSeq;
        }
        authSeqID = p_xelement.getSingleTextNotNull("AuthSeqID");
        useType = p_xelement.getSingleTextNotNull("UseType");
        //purpose = p_xelement.getSingleTextNotNull("Purpose");
        //20181128老邬决定的
        //中原银行着急上U6,这里根据中原银行这边的业务需求purpose需求取用途，saas传给DSP的批量报文没有Purpose字段，导致下面又去取Memo备注了，这样不符合需求，所以改成取Usage这个用途
        purpose = p_xelement.getSingleTextNotNull("Usage");
        if ("1908".equals(p_transType) || "9108".equals(p_transType) || "6908".equals(p_transType) || "9110".equals(p_transType) || "9109".equals(p_transType) || "PurchaseFCP".equals(p_transType) || "SettleFCP".equals(p_transType) || "1908BAT".equals(p_transType) || "CrossborderFCP".equals(p_transType) || "DomesticFCP".equals(p_transType) || "OutsideFCP".equals(p_transType) || "Contract".equals(p_transType) || "QryContract".equals(p_transType) || "QryBatContract".equals(p_transType) || "UpContract".equals(p_transType)) {
            askNumber = p_xelement.getSingleText("ReqSeqID");
            abstractATS = p_xelement.getSingleText("PostScript");
            if (StringHelper.isNullOrEmpty(purpose)) {
                purpose = p_xelement.getSingleTextNotNull("Usage");
            }
        } else if ("1988".equals(p_transType) || "9188".equals(p_transType) || "1988-ReSend".equals(transType) || "9188-ReSend".equals(transType)) {
            askNumber = p_xelement.getSingleText("PostScript");//支付批号内唯一
            abstractATS = p_xelement.getSingleText("ReqReserve");
            costMode = p_xelement.getSingleText("CostMode");
            if (StringHelper.isNullOrEmpty(useType)) {
                useType = p_xelement.getSingleTextNotNull("Usage");
            }
            if (StringHelper.isNullOrEmpty(purpose)) {
                purpose = p_xelement.getSingleTextNotNull("Memo");
            }
            if (StringHelper.isNullOrEmpty(purpose)) {
                purpose = p_xelement.getSingleTextNotNull("Usage");
            }
        } else if("9208".equals(p_transType) || "9288".equals(p_transType)){
            abstractATS = p_xelement.getSingleText("PostScript");
            askNumber = p_xelement.getSingleText("SequenceNo");//支付批号内唯一编号
        } else {
            throw new Exception("PayRecDetail不支持的TransType：" + p_transType);
        }
        payName = p_xelement.getSingleText("PayName");
        payAct = p_xelement.getSingleText("PayAct");
        payBankName = p_xelement.getSingleTextNotNull("PayBankName");
        payBankCode = p_xelement.getSingleTextNotNull("PayBankCode");
        payBankLocation = p_xelement.getSingleText("PayBnk");
        payBankLocationCode = p_xelement.getSingleText("PayBankLocationCode");
        payOrganizationCode = p_xelement.getSingleText("PayOrgCode");
        payArea = p_xelement.getSingleText("PayArea");
        payAreaName = p_xelement.getSingleText("PayAreaName");
        if (FGBiz.dspCenter.convertBankArea) {
            BankAreaHelper bankAreaHelper = new BankAreaHelper(p_bankCode, payArea, "");
            bankAreaHelper.toBank();
            payArea = bankAreaHelper.bankAreaCode;
            payAreaName = bankAreaHelper.bankAreaName;
        }
        //境外支付新增字段Start
        recBankInEng = p_xelement.getSingleTextNotNull("RecBankAddr");
        payCountryCode = p_xelement.getSingleTextNotNull("PayCountryCode");
        popCode=  p_xelement.getSingleTextNotNull("REM_MODE");
        feePayer = p_xelement.getSingleTextNotNull("FeePayer");
        recSwiftCode = p_xelement.getSingleTextNotNull("BankSwfitCode");
        payOrgCode = p_xelement.getSingleTextNotNull("ApplyName");
        if (StringHelper.isNullOrEmpty(payOrgCode)) {
            payOrgCode = p_xelement.getSingleTextNotNull("UNITCODE");
        }
        recCountry = p_xelement.getSingleTextNotNull("RecCountry");
        isBondedGood = p_xelement.getSingleTextNotNull("FundProp");
        payMethod = p_xelement.getSingleTextNotNull("REM_MODE");
        transCode1 = p_xelement.getSingleTextNotNull("TranNos");
        currency1 = p_xelement.getSingleTextNotNull("RecAgtBankName");
        recAgtBankName = p_xelement.getSingleTextNotNull("RecAgtBankName");
        amount1 = p_xelement.getSingleTextNotNull("RecAgeBankAddr");
        recAgeBankAddr = p_xelement.getSingleTextNotNull("RecAgeBankAddr");
        transRemark1 = p_xelement.getSingleTextNotNull("ActingBankAccount");
        transCode2 = p_xelement.getSingleTextNotNull("CUS_FLAG");
        currency2 = p_xelement.getSingleTextNotNull("REM_TYP");
        amount2 = p_xelement.getSingleTextNotNull("Phone");
        transRemark2 = p_xelement.getSingleTextNotNull("Iban");
        contractNo = p_xelement.getSingleTextNotNull("BankOthers");
        if (StringHelper.isNullOrEmpty(contractNo)) {
        	contractNo = p_xelement.getSingleTextNotNull("comnum");
        }
        if (StringHelper.isNullOrEmpty(contractNo)) {
        	contractNo = p_xelement.getSingleTextNotNull("ContractNo");
        }
        invoiceNo = p_xelement.getSingleTextNotNull("RecBankCity");
        if (StringHelper.isNullOrEmpty(invoiceNo)) {
        	invoiceNo = p_xelement.getSingleTextNotNull("InvNum");
        }
        if (StringHelper.isNullOrEmpty(invoiceNo)) {
        	invoiceNo = p_xelement.getSingleTextNotNull("InvoiceNo");
        }
        safeOrFillingNo = p_xelement.getSingleTextNotNull("InterimBankOthers");
        transCode = p_xelement.getSingleTextNotNull("TranNos");
        remittanceInfor = p_xelement.getSingleTextNotNull("RemittanceInfor");
        //境外支付新增字段End
        payStandardArea = p_xelement.getSingleTextNotNull("PayStandardArea");
        payType = p_xelement.getSingleTextNotNull("PayType");
     
        // 薪资代发时收方卡号、户名、金额均需进行解密
        recAct = p_xelement.getSingleText("RecAct");
        recName = p_xelement.getSingleText("RecName");
        payAmount = p_xelement.getSingleText("PayAmount");
        if ("F020".equals(pPayType)) {
        	recAct = TripleDESHelper.decryptCBC(recAct);
        	recName = TripleDESHelper.decryptCBC(recName);
        	payAmount = TripleDESHelper.decryptCBC(payAmount);
        }
        recBankName = p_xelement.getSingleTextNotNull("RecBankName");
        recBankCode = p_xelement.getSingleTextNotNull("RecBankCode");
        recBankLocation = p_xelement.getSingleText("RecBnk");
        recArea = p_xelement.getSingleText("RecArea");
        recAreaName = p_xelement.getSingleText("RecAreaName");
        if (FGBiz.dspCenter.convertBankArea) {
            BankAreaHelper bankAreaHelper = new BankAreaHelper(p_bankCode, recArea, "");
            bankAreaHelper.toBank();
            recArea = bankAreaHelper.bankAreaCode;
            recAreaName = bankAreaHelper.bankAreaName;
        }
        recStandardArea = p_xelement.getSingleTextNotNull("RecStandardArea");
        sameCity = p_xelement.getSingleTextNotNull("SameCity");
        sameBnk = p_xelement.getSingleTextNotNull("SameBnk");
        payDate = p_xelement.getSingleText("PayDate");
        payTime = p_xelement.getSingleText("PayTime");
        payCur = p_xelement.getSingleTextNotNull("PayCur");
        recCur = p_xelement.getSingleTextNotNull("RecCur");
        paySpd = p_xelement.getSingleTextNotNull("PaySpd");
        submitID = p_xelement.getSingleTextNotNull("SubmitID");
        verifyFlag = p_xelement.getSingleTextNotNull("VerifyFlag");

        memo = p_xelement.getSingleTextNotNull("Memo");
        description = p_xelement.getSingleTextNotNull("Description");
        innerPay = p_xelement.getSingleTextNotNull("InnerPay");
        rootPay = p_xelement.getSingleTextNotNull("RootPay");
        rootRec = p_xelement.getSingleTextNotNull("RootRec");
        cardType = p_xelement.getSingleTextNotNull("CardType");
        if (StringHelper.isNullOrEmpty(cardType)) {
        	cardType = "2";
        }
        isPrivate = p_xelement.getSingleTextNotNull("IsPrivate");
        cnapsCode = p_xelement.getSingleTextNotNull("CNAPSCode");
        if ("999999999999".equals(cnapsCode)) {
            cnapsCode = "";
        }
        cnapsName = p_xelement.getSingleTextNotNull("CNAPSName");

        certType = p_xelement.getSingleTextNotNull("CertType");

        if (StringHelper.isNullOrEmpty(certType)) {
        	certType = "0";
        }
        certNum = p_xelement.getSingleTextNotNull("CertNum");
        
        sourceNote = p_xelement.getSingleTextNotNull("SourceNote");
        sourceNoteCode = p_xelement.getSingleTextNotNull("SourceNoteCode");
        oriSourceNoteCode=p_xelement.getSingleTextNotNull("SourceNoteCode");

        if(StringHelper.isNullOrEmpty(sourceNote)){
        	sourceNote = sourceNoteCode;
        }
        if(StringHelper.isNullOrEmpty(sourceNoteCode)){
        	sourceNoteCode = sourceNote;
        }
        cellPhone = p_xelement.getSingleTextNotNull("CellPhone");
        if (cellPhone.length() == 0) {
            cellPhone = p_xelement.getSingleTextNotNull("Mobile");
        }

        expiredDate = p_xelement.getSingleTextNotNull("ExpiredDate");
        if (expiredDate.length() == 0) {
            expiredDate = p_xelement.getSingleTextNotNull("ValidDate");
            if (expiredDate.length() == 0) {
                expiredDate = p_xelement.getSingleTextNotNull("CreditCardValidity");
            }
        }
        cvv2 = p_xelement.getSingleTextNotNull("CVV2");
        if (cvv2.length() == 0) {
            cvv2 = p_xelement.getSingleTextNotNull("cvv2");
            if (cvv2.length() == 0) {
                cvv2 = p_xelement.getSingleTextNotNull("CreditCardSecCode");
            }
        }

        authAgNum = p_xelement.getSingleTextNotNull("AuthAgNum");
        authCode = p_xelement.getSingleTextNotNull("AuthCode");

        if (StringHelper.isNullOrEmpty(authCode)) {
            authCode = p_xelement.getSingleTextNotNull("ReqReserved1");
        }

        smsCode = p_xelement.getSingleTextNotNull("SmsCode");

        if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
            ownBankCode = p_xelement.getSingleTextNotNull("PayBankCode");
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            ownBankCode = p_xelement.getSingleTextNotNull("RecBankCode");
        }
        primaryAct = p_xelement.getSingleTextNotNull("PrimaryAct");
        coucde = p_xelement.getSingleTextNotNull("OppCountryCode");
        payTopLevelAct = p_xelement.getSingleTextNotNull("PayTopLevelAct");
        payHigherLevelAct = p_xelement.getSingleTextNotNull("PayHigherLevelAct");
        recTopLevelAct = p_xelement.getSingleTextNotNull("RecTopLevelAct");
        recHigherLevelAct = p_xelement.getSingleTextNotNull("RecHigherLevelAct");

        innerAct = p_xelement.getSingleTextNotNull("InnerAct");
        innerName = p_xelement.getSingleTextNotNull("InnerName");

        reqReserved1 = p_xelement.getSingleTextNotNull("ReqReserved1");
        reqReserved2 = p_xelement.getSingleTextNotNull("ReqReserved2");
        isCardBind = p_xelement.getSingleTextNotNull("IsCardBind");
        userId = p_xelement.getSingleTextNotNull("UserId");
        shortCardNo = p_xelement.getSingleTextNotNull("ShortCardNo");
        shortPhoneNo = p_xelement.getSingleTextNotNull("ShortPhoneNo");
        attach = p_xelement.getSingleTextNotNull("Attach");
        bookDate= p_xelement.getSingleTextNotNull("BookDate");
        workDayFlag = p_xelement.getSingleTextNotNull("WorkDayFlag");
        reuseSeq = p_xelement.getSingleTextNotNull("ReuseSeq");
        insuPolicyNum = p_xelement.getSingleTextNotNull("InsuPolicyNum");
        if (StringHelper.isNullOrEmpty(insuPolicyNum)) {
            insuPolicyNum = p_xelement.getSingleTextNotNull("PolicyNo");
        }
        insureID = p_xelement.getSingleTextNotNull("InsureID");
        insureName = p_xelement.getSingleTextNotNull("InsureName");
        noteMoney = p_xelement.getSingleTextNotNull("NoteMoney");
        recBankAddress = p_xelement.getSingleTextNotNull("RecBankAddr");
        recNameAddress = p_xelement.getSingleTextNotNull("RecAddr");
        if(StringHelper.isNullOrEmpty(recNameAddress)){
        	recNameAddress = p_xelement.getSingleTextNotNull("RecNameAddr");
        }
        if(StringHelper.isNullOrEmpty(recNameAddress)){
        	recNameAddress = p_xelement.getSingleTextNotNull("RecnNameAddr");
        }
        recAgentBankAccount = p_xelement.getSingleTextNotNull("ActingBankAccount");
        isBondedGoods = p_xelement.getSingleTextNotNull("IsBondedGoods");
        orgCode = p_xelement.getSingleTextNotNull("OrgCode");
        payProp = p_xelement.getSingleTextNotNull("PayProp");
        transInfo = p_xelement.getSingleTextNotNull("TransInfo");
        realNameFlag = p_xelement.getSingleTextNotNull("RealNameFlag");
        if ("1".equals(realNameFlag)) {
        	sourceNoteCode = p_xelement.getSingleTextNotNull("PaymentNo");
        }
        realNameType = p_xelement.getSingleTextNotNull("RealNameType");
        circPaymentNo = p_xelement.getSingleTextNotNull("CircPaymentNo");
        circMchNo = p_xelement.getSingleTextNotNull("CircMchNo");
        userCode = p_xelement.getSingleTextNotNull("UserCode");
        userName = p_xelement.getSingleTextNotNull("UserName");
        authId = p_xelement.getSingleTextNotNull("AuthId");
        paymentCode = p_xelement.getSingleTextNotNull("PaymentCode");
        bkName = p_xelement.getSingleTextNotNull("BkName");
        lioperType = p_xelement.getSingleTextNotNull("LioperType");
        branchCode = p_xelement.getSingleTextNotNull("BranchCode");
        channel = p_xelement.getSingleTextNotNull("Channel");
        customNo = p_xelement.getSingleTextNotNull("CustomNo");
        createIP = p_xelement.getSingleTextNotNull("CreateIP");
        channelAuthCode = p_xelement.getSingleTextNotNull("ChannelAuthCode");
        termID = p_xelement.getSingleTextNotNull("TermID");
        budgetItemCode = p_xelement.getSingleTextNotNull("BudgetItemCode");
        if ("1".equals(p_xelement.getSingleTextNotNull("IsVirtual"))) {
            isVirtual = true;
        } else {
            isVirtual = false;
        }
        virtualNo = p_xelement.getSingleTextNotNull("VirtualNo");
        attribute11 = p_xelement.getSingleTextNotNull("Attribute11");
        attribute12 = p_xelement.getSingleTextNotNull("Attribute12");
        attribute13 = p_xelement.getSingleTextNotNull("Attribute13");
        attribute14 = p_xelement.getSingleTextNotNull("Attribute14");
        attribute15 = p_xelement.getSingleTextNotNull("Attribute15");
        attribute16 = p_xelement.getSingleTextNotNull("Attribute16");
        attribute17 = p_xelement.getSingleTextNotNull("Attribute17");
        attribute18 = p_xelement.getSingleTextNotNull("Attribute18");
        attribute19 = p_xelement.getSingleTextNotNull("Attribute19");
    }

    public String getUseTypeAndPurpose(String p_splitChar) {
        return this.useType + p_splitChar + this.purpose;
    }

    public Date getPayDateOnly() throws ParseException {
        return Format.Date10Format.parse(payDate);
    }

    public Date getPayDateTime() throws ParseException {
        return Format.DateTimeFormat.parse(payDate + " " + payTime);
    }

    public BigDecimal getPayAmount() {
        return new BigDecimal(payAmount);
    }

    public boolean isLargeAmt() {
        float tmpAmt = Float.parseFloat(payAmount);
        if (tmpAmt > 50000) {
            return true;
        }
        return false;
    }

    public String getOppBankLocation() {
        if (cnapsName != null && cnapsName.length() > 0) {
            return cnapsName;
        } else if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
            if (recBankLocation != null && recBankLocation.length() > 0) {
                return this.recBankLocation;
            } else {
                return recBankName;
            }
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            if (payBankLocation != null && payBankLocation.length() > 0) {
                return this.payBankLocation;
            } else {
                return payBankName;
            }
        } else {
            return "";
        }
    }

    public String getOppStandardArea() {
        return getOppAreaName().replace("_", "");
    }

    /**取对方区域名称，优先AreaName，其次StandardArea*/
    public String getOppAreaName2() {
        String areaName = "";
        if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
            if (recAreaName != null && recAreaName.length() > 0) {
                areaName = recAreaName;
            } else if (recStandardArea != null && recStandardArea.length() > 0) {
                areaName = recStandardArea;
            }
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            if (payAreaName != null && payAreaName.length() > 0) {
                areaName = payAreaName;
            } else if (payStandardArea != null && payStandardArea.length() > 0) {
                areaName = payStandardArea;
            }
        }
        return areaName;
    }

    /**取对方区域名称，优先StandardArea，其次AreaName*/
    public String getOppAreaName() {
        String areaName = "";
        if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
            if (recStandardArea != null && recStandardArea.length() > 0) {
                areaName = recStandardArea;
            } else if (recAreaName != null && recAreaName.length() > 0) {
                areaName = recAreaName;
            }
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            if (payStandardArea != null && payStandardArea.length() > 0) {
                areaName = payStandardArea;
            } else if (payAreaName != null && payAreaName.length() > 0) {
                areaName = payAreaName;
            }
        }
        return areaName;
    }
    
    public String getOppArea() {
        if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
        	return recArea;
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            return payArea;
        }
        return "";
    }
    
    public String getOppBankCode() {

        if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
            return this.recBankCode;
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            return this.payBankCode;
        }
        return "";
    }

    public String getOppBankName() {

        if ("1908".equals(transType) || "6908".equals(transType) || "1988".equals(transType) || "1988-ReSend".equals(transType)) {
            return this.recBankName;
        } else if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            return this.payBankName;
        }
        return "";
    }

    public String[] getOppProvinceAndCity() {
        String[] retStr = new String[]{"", ""};
        String[] tmpPC = getOppAreaName().split("_");

        String tmpProvince = tmpPC[0];
        tmpProvince = tmpProvince.replace("省", "").replace("市", "").replace("壮族自治区", "");
        tmpProvince = tmpProvince.replace("维吾尔自治区", "").replace("回族自治区", "").replace("自治区", "");
        retStr[0] = tmpProvince;
        if (tmpPC.length > 1) {
            retStr[1] = tmpPC[1].replace("市", "");
        }
        return retStr;
    }

    public String[] getOppProvinceAndCity2() {
        String[] retStr = new String[]{"", ""};
        String[] tmpPC = getOppAreaName2().split("_");

        String tmpProvince = tmpPC[0];
        tmpProvince = tmpProvince.replace("省", "").replace("市", "").replace("壮族自治区", "");
        tmpProvince = tmpProvince.replace("维吾尔自治区", "").replace("回族自治区", "").replace("自治区", "");
        retStr[0] = tmpProvince;
        if (tmpPC.length > 1) {
            retStr[1] = tmpPC[1].replace("市", "");
        }
        return retStr;
    }

    public String getOppCur() {
        if ("9108".equals(transType) || "9188".equals(transType) || "9188-ReSend".equals(transType) || "9110".equals(transType)) {
            if (StringHelper.hasAnyChar(recCur)) {
                return recCur;
            }
        }
        return payCur;
    }

    /**
     * 跨行同城普通（非加急）
     */
    public boolean isCrossBankSameCityOrdinary() {
        if (!"1".equals(sameBnk) && "1".equals(sameCity) && !"1".equals(paySpd)) {
            return true;
        }
        return false;
    }
    
    /**
     * 取cnapsCode,过滤12个9
     * */
    public String getCnapsCodeNot999(){
    	if(!"999999999999".equals(cnapsCode)){
    		return cnapsCode;
    	}else{
    		return "";
    	}
    }
}
